package com.ysu.demo.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;

import java.util.Date;

/**
 * @author ：lhw
 * @date ：Created in 2019/8/2 10:36
 */
public class MybatisConfig implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createTime",new Date(),metaObject);
        this.setFieldValByName("updateTime",new Date(),metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updateTime",new Date(),metaObject);

//        Object et = metaObject.getValue("et");
//        MetaObject etMeta = SystemMetaObject.forObject(et);
//        etMeta.setValue("updateTime",new Date());
    }

}
